package com.spodrum.balloon;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;

public class Medal implements UpdateableI
{
	//The medal gets bigger and smaller after each update/render.
	
	public Drawable image;
	public int x, y; //this is the center location of the image.
	private Rect rect;
	private int current_width, current_height, max_width, min_width;
	private float ratio;
	private Speed speed;
	
	public Medal(Drawable image, int x, int y)
	{
		this.image = image;
		
		this.min_width = image.getIntrinsicWidth() - image.getIntrinsicWidth()/3;
		this.max_width = image.getIntrinsicWidth() + image.getIntrinsicWidth()/2;
		
		this.current_width = image.getIntrinsicWidth();
		this.current_height = image.getIntrinsicHeight();
		this.ratio = (float) image.getIntrinsicWidth() / (float) image.getIntrinsicHeight();
		
		this.x = x;
		this.y = y;
		this.rect = new Rect(x - image.getIntrinsicWidth()/2, y - image.getIntrinsicHeight()/2, x + image.getIntrinsicWidth()/2 , y + image.getIntrinsicHeight()/2);
		this.speed = new Speed(10,10);
	}

	public void render(Canvas canvas)
	{
		image.setBounds(rect);
		image.draw(canvas);
	}
	
	@Override
	public void update() 
	{
		//adjust bounds
		current_width += (speed.getXv() * speed.getxDirection()); 
		current_height = (int) (current_width/ratio); //(speed.getYv() * speed.getyDirection());
		rect.set(x - current_width/2, y - current_height/2, x + current_width/2 , y + current_height/2);
		//paint.setTextSize(textSize += (speed.getXv() * speed.getxDirection()));
		
		if(current_width >= max_width || current_width <= min_width)
		{
			speed.toggleXDirection();
			speed.toggleYDirection();
		}
	}
	
	

}
